package cz.via.wowss.service;

import cz.via.wowss.dao.GameDao;
import cz.via.wowss.helper.UserSessionProvider;

public class SecurityService {

	public boolean logon(String name, String password, UserSessionProvider usp) {
//		boolean success = true;
		// TODO: Pripojeni do DB, kontrola jmena a hesla, ziskani ID
		
		GameDao gd = new GameDao();
		
		int id = gd.logon(name, password);
		
		if(id < 0) {
			usp.setAuthenticated(false);
			return false;
		} else {
			usp.setAuthenticated(true);
			usp.setName(name);
			usp.setId(id);
			return true;
		}
		
//		int id = 1;
//		usp.setAuthenticated(success);
//		usp.setName(name);
//		usp.setId(id);
//		return success;
	}
}
